<template>
  <div id="bix">
    <div id="topInfo">
      <div class="title_gailan_middle">
        <div class="title_gailan_top">网络医院</div>
        <div class="fontWhite">
          <div class="title_gailan_radio jrsf">
            <span class="title_gailan_left_middle">
              <span class="font13">今日已随访</span>
            </span>
            <span class="title_gailan_line">|</span>
            <span class="title_gailan_right_middle">
              <span id="wlyy_jrsf">{{ over1 }}</span>
              <span class="title_gailan_right_middle_span font13">（人）</span>
            </span>
          </div>
          <div class="title_gailan_radio jrysf">
            <span class="title_gailan_left_middle">
              <span class="font13">今日应随访</span>
            </span>
            <span class="title_gailan_line">|</span>
            <span class="title_gailan_right_middle">
              <span id="wlyy_jrysf">{{ totals1 }}</span>
              <span class="title_gailan_right_middle_span font13">（人）</span>
            </span>
          </div>
        </div>
      </div>
      <div class="title_gailan_middle">
        <div class="title_gailan_top">筛查门诊</div>
        <div class="fontWhite">
          <div class="title_gailan_radio jrsf">
            <span class="title_gailan_left_middle">
              <span class="font13">今日已随访</span>
            </span>
            <span class="title_gailan_line">|</span>
            <span class="title_gailan_right_middle">
              <span id="scmz_jrsf">{{ over2 }}</span>
              <span class="title_gailan_right_middle_span font13">（人）</span>
            </span>
          </div>
          <div class="title_gailan_radio jrysf">
            <span class="title_gailan_left_middle">
              <span class="font13">今日应随访</span>
            </span>
            <span class="title_gailan_line">|</span>
            <span class="title_gailan_right_middle">
              <span id="scmz_jrysf">{{ totals2 }}</span>
              <span class="title_gailan_right_middle_span font13">（人）</span>
            </span>
          </div>
        </div>
      </div>
      <div class="title_gailan_middle">
        <div class="title_gailan_top">绿色通道</div>
        <div class="fontWhite">
          <div class="title_gailan_radio jrsf">
            <span class="title_gailan_left_middle">
              <span class="font13">今日随访</span>
            </span>
            <span class="title_gailan_line">|</span>
            <span class="title_gailan_right_middle">
              <span id="sh_jrsf">{{ over3 }}</span>
              <span class="title_gailan_right_middle_span font13">（人）</span>
            </span>
          </div>
          <div class="title_gailan_radio jrysf">
            <span class="title_gailan_left_middle">
              <span class="font13">今日应随访</span>
            </span>
            <span class="title_gailan_line">|</span>
            <span class="title_gailan_right_middle">
              <span id="sh_jrysf">{{ totals3 }}</span>
              <span class="title_gailan_right_middle_span font13">（人）</span>
            </span>
          </div>
        </div>
      </div>
    </div>
    <!-- topInfo_Ended -->
    <div id="btmInfo">
      <el-card id="queryForm" shadow="never">
        <div id="btmForm">
          <el-form :inline="true" class="demo-form-inline">
            <el-form-item
              label="姓名 :"
            ><el-input
              v-model="formInline.patName"
              placeholder="姓名"
              style="width: 90px"
            /></el-form-item>
            <el-form-item label="慢病等级:">
              <el-select
                v-model="formInline.chronicDiseaseGrade"
                clearable
                style="width: 140px"
              >
                <el-option
                  v-for="item in options13"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="随访计划:">
              <el-select
                v-model="formInline.planId"
                clearable
                style="width: 140px"
              >
                <el-option
                  v-for="item in options15"
                  :key="item.planId"
                  :label="item.planName"
                  :value="item.planId"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="时间范围:">
              <el-date-picker
                v-model="value1"
                style="width: 360px"
                type="datetimerange"
                value-format="yyyy-MM-dd HH:mm:ss"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              />
            </el-form-item>
            <el-form-item><el-button
              @click="show3 = !show3"
            >高级查询</el-button></el-form-item>
            <el-form-item><el-button
              type="primary"
              @click="queryinformation()"
            >查询</el-button></el-form-item>
            <el-form-item><el-button
              type="primary"
              @click="reset()"
            >重置</el-button></el-form-item>
          </el-form>
        </div>
        <div v-show="show3" id="btmForm" style="margin-top: -20px; width: 100%">
          <el-form :inline="true" class="demo-form-inline">
            <el-form-item label="患者类型:">
              <el-select
                v-model="formInline.patTypeCode"
                clearable
                style="width: 140px"
              >
                <el-option
                  v-for="item in options12"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="性别:">
              <el-select
                v-model="formInline.patSexName"
                clearable
                style="width: 140px"
              >
                <el-option
                  v-for="item in options"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="随访医生:">
              <el-select
                v-model="formInline.userId"
                filterable
                clearable
                style="width: 140px"
              >
                <el-option
                  v-for="item in options4"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="年龄段" label-width="64px">
              <el-input
                v-model="formInline.ageRangeEnd"
                clearable
                :style="{ width: '80px' }"
              />
            </el-form-item>
            <el-form-item label="至" label-width="36px">
              <el-input
                v-model="formInline.ageRangeStart"
                clearable
                :style="{ width: '160px' }"
              >
                <template slot="append">岁</template>
              </el-input>
            </el-form-item>
          </el-form>
        </div>
        <div id="btmTable">
          <el-tabs
            v-model="tabCheck"
            type="border-card"
            @tab-click="handleClick"
          >
            <el-tab-pane label="全部" />
            <el-tab-pane label="待随访" name="waitFollowup" />
            <el-tab-pane label="已随访" name="endlistFollowup" />
            <el-tab-pane label="已取消" name="cancelFollowup" />

            <el-row type="flex" justify="end">
              <!-- <el-col style="text-align: right">
                <el-popover placement="left-start" width="150" trigger="click">
                  <div class="filter-container">
                    <el-checkbox-group v-model="checkboxVal">
                      <el-checkbox
                        v-for="checkbox in checkboxsLabel"
                        :key="checkbox.checkboxVal"
                        :label="checkbox.checkboxVal"
                        >{{ checkbox.theadName }}</el-checkbox
                      >
                    </el-checkbox-group>
                  </div>
                  <el-button
                    size="mini"
                    class="filter-item"
                    slot="reference"
                    style="margin-right: 10px;margin-top: 10px"
                    icon="el-icon-s-operation"
                  >
                    筛选列
                  </el-button>
                </el-popover>

                <el-button
                  class="filter-item"
                  size="mini"
                  icon="el-icon-download"
                  @click="getTemplate"
                  >批量导出</el-button
                >
                <el-button class="filter-item" size="mini" type="primary">
                  <span>
                    <svg-icon class-name="funcIcon" icon-class="print" />
                  </span>
                  打印
                </el-button>

                <el-button
                  class="filter-item"
                  size="mini"
                  @click="click_on_immediate_follow_up()"
                  >立即随访</el-button
                >
              </el-col> -->

              <el-button
                type="primary"
                @click="click_on_immediate_follow_up()"
              >新增随访</el-button>
            </el-row>

            <div id="tableData" style="width: 100%; margin-top: 15px">
              <el-table :data="tableData" border @row-click="getRowKey">
                <!-- <el-table-column type="selection" width="55" align="center" /> -->
                <el-table-column
                  type="index"
                  width="50"
                  label="编号"
                  align="center"
                />

                <el-table-column prop="patName" label="姓名" align="center" />
                <el-table-column prop="patId" label="患者编码" width="180" align="center" />
                <el-table-column prop="planPatTime" label="随访计划时间" width="180" align="center" />
                <el-table-column prop="patSexName" label="性别" width="100" align="center" />
                <el-table-column prop="age" label="年龄" width="100" align="center" />
                <el-table-column label="患者类型" width="300" align="center">
                  <template slot-scope="scope">
                    {{ comCodeList.get("pat_type").get(scope.row.patTypeCode) }}
                  </template>
                </el-table-column>
                <el-table-column label="随访周期" align="center">
                  <template slot-scope="scope">
                    {{
                      comCodeList
                        .get("plan_cycle")
                        .get(scope.row.planCycleCode)
                        .replace("个", "") +
                        comCodeList
                          .get("plan_frequency")
                          .get(scope.row.planFrequencyCode)
                    }}
                  </template>
                </el-table-column>
                <el-table-column
                  prop="planPatNextFollowStartTime"
                  label="下次随访时间"
                  width="180"
                  align="center"
                />
                <el-table-column label="随访方式" align="center">
                  <template slot-scope="scope">
                    {{
                      comCodeList
                        .get("follow_way")
                        .get(scope.row.planFollowWayCode)
                    }}
                  </template>
                </el-table-column>
                <el-table-column
                  prop="userName"
                  align="center"
                  label="随访负责医生"
                />
                <el-table-column align="center" label="随访状态">
                  <template slot-scope="scope">
                    {{
                      comCodeList
                        .get("follow_status")
                        .get(scope.row.planPatFollowStatusCode)
                    }}
                  </template>
                </el-table-column>

                <!--  <el-table-column
                  align="center"
                  min-width="103px"
                  v-for="formTheadName in formThead"
                  :key="formTheadName.checkboxVal"
                  :label="formTheadName.theadName"
                >
                  <template slot-scope="scope">{{
                    scope.row[formTheadName.checkboxVal]
                  }}</template>
                </el-table-column>-->
                <el-table-column
                  label="操作"
                  fixed="right"
                  align="center"
                  width="150"
                >
                  <template slot-scope="scope">
                    <div>
                      <el-button
                        type="text"
                        @click.native.stop="
                          theechos(
                            scope.row.planPatId,
                            scope.row.planPatFollowStatusCode
                          )
                        "
                      >取消随访</el-button>
                      <el-button
                        type="text"
                        @click.native.stop="removethebaseline(scope.row)"
                      >立即随访</el-button>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
              <el-pagination
                background
                :current-page.sync="pageNum"
                :page-sizes="pageSizes"
                layout="total,prev, pager, next,sizes"
                :total="total"
                @size-change="changeSize"
                @current-change="changePage"
              />
            </div>
          </el-tabs>
        </div>
      </el-card>
    </div>
  </div>
</template>
<script>
import {
  queryListGet,
  queryFollowupNum
} from '@/api/follow-up/follow-up-records'
import { followuprecords } from '@/api/follow-up/follow-up-records' // 随访记录
import { domaininterface } from '@/api/follow-up/follow-up-records' // 值域接口
import { followupplan } from '@/api/follow-up/follow-up-records' // 随访计划
import { thedoctor } from '@/api/follow-up/follow-up-records' // 医生下拉选
import { thebatchexport } from '@/api/follow-up/follow-up-records' // 批量导出
import { cancelthefollowup } from '@/api/follow-up/follow-up-records' // 取消随访
import { statisticalquery } from '@/api/follow-up/follow-up-records' // 查询统计
import axios from 'axios'
import { planpat } from '@/api/back-management/follow_up_plan'
// file:///D:/svnTest/code/trunk/yzy_web_vue/src/api/follow-up/follow-up-records.js
const defaultFormThead = [
  'planPatTime',
  'patCode',
  'patName',
  'patSexName',
  'age',
  'memPatTypeCode',
  'planCycleName',
  'planPatNextFollowStartTime',
  'planFollowWayName',
  'userName',
  'planPatFollowStatusName'
]
export default {
  data() {
    return {
      comCodeList: new Map(),
      memPatTypeCode: '',
      formInline: {
        chronicDiseaseGrade: '', // 慢病等级
        planId: '', // 随方计划
        ageRangeEnd: '',
        ageRangeStart: '',
        patName: '', // 姓名
        patTypeCode: '',
        patSexName: '',
        sex: '',
        // age:"",
        userId: ''
      },
      checkboxsLabel: [
        { checkboxVal: 'planPatTime', theadName: '任务完成时间' },
        { checkboxVal: 'patCode', theadName: '患者编号' },
        { checkboxVal: 'patName', theadName: '姓名' },
        { checkboxVal: 'patSexName', theadName: '性别' },
        { checkboxVal: 'age', theadName: '年龄' },
        { checkboxVal: 'memPatTypeCode', theadName: '患者类型' },
        { checkboxVal: 'planCycleName', theadName: '随访周期' },
        {
          checkboxVal: 'planPatNextFollowStartTime',
          theadName: '下次随访时间'
        },
        { checkboxVal: 'planFollowWayName', theadName: '随访方式' },
        { checkboxVal: 'userName', theadName: '随访负责医生' },
        { checkboxVal: 'planPatFollowStatusName', theadName: '随访状态' }
      ],
      checkboxVal: defaultFormThead, // checkboxVal
      tabCheck: 'allFollowup',
      over1: '',
      totals1: '',
      over2: '',
      totals2: '',
      over3: '',
      totals3: '',

      value1: ['', ''],
      options: [],
      options4: [],
      options12: [],
      options13: [],
      options15: [],

      // followupState: "1", // 查询类型 (待随访,已随访,已取消,全部)
      followupStateList: {
        waitFollowup: 1,
        endlistFollowup: 2,
        cancelFollowup: 3
      },
      formThead: [], // 默认表头 Default header

      dialogFormVisible: false,
      form_items_status: false,
      show3: false,
      // 总数据
      tableData: [],
      total: 0,
      // 默认显示第几页
      pageNum: 1,
      pageSize: 10,
      // 总条数，根据接口获取数据长度(注意：这里不能为空)
      // 个数选择器（可修改）
      pageSizes: [10, 20, 50]
    }
  },
  watch: {
    checkboxVal(valArr) {
      this.formThead = this.checkboxsLabel.filter(i =>
        valArr.includes(i.checkboxVal)
      )
      this.key = this.key + 1 // 为了保证table 每次都会重渲 In order to ensure the table will be re-rendered each time
    },
    // 患者类型
    'formInline.patTypeCode': {
      deep: true,
      handler(newValue, oldValue) {
        // console.log('watch---------------------', newValue)
        this.formInline.memPatTypeCode = this.comCodeList
          .get('pat_type')
          .get(newValue)
      }
    },
    // 性别下拉选的转换
    'formInline.patSexName': {
      deep: true,
      handler(newValue, oldValue) {
        // console.log('watch---------------------', newValue)
        this.formInline.sex = this.comCodeList.get('sex').get(newValue)
      }
    }
  },

  created() {
    this.getDeptData13()
    this.getDeptData15()
    this.getDeptData()
    this.getDeptData4()

    // 需要顺序执行的值域
    this.getDeptData12(this.getDeptData16)
    this.formThead = this.checkboxsLabel.filter(item =>
      this.checkboxVal.includes(item.checkboxVal)
    )
  },
  mounted() {
    // this.initSelectCategoryss();
    this.initSelectCategoryss1()
    this.initSelectCategoryss2()
    this.initSelectCategoryss3()
  },

  methods: {
    getNameByCode(type, code) {
      return this.comCodeList.get(type).get(code)
    },
    calStar(curr) {
      let pageNum = this.pageNum
      pageNum = (curr - 1) * this.pageSize
      return pageNum
    },
    // 显示
    initSelectCategoryss() {
      const params = {
        length: this.pageSize,
        start: this.calStar(this.pageNum),
        planPatTimeEnd:
          this.value1 == null ? '' : this.value1[0] ? this.value1[1] : '', // 任务开始
        planPatTimeStart:
          this.value1 == null ? '' : this.value1[0] ? this.value1[0] : '', // 任务完成结束
        patName: this.formInline.patName, // 姓名
        patSexName: this.formInline.sex, // 性别
        // chronicDiseaseGrade: this.chronicDiseaseGrade, //等级
        patTypeCode: this.formInline.patTypeCode,
        chronicDiseaseGrade: this.formInline.chronicDiseaseGrade,
        // patSexName: this.formInline.patSexName,
        ageRangeEnd: this.formInline.ageRangeEnd,
        ageRangeStart: this.formInline.ageRangeStart,
        userId: this.formInline.userId,
        planId: this.formInline.planId,
        planPatFollowStatusCode: this.followupState
      }
      // alert(id)
      followuprecords(params).then(res => {
        // console.log('initSelectCategoryss')
        this.tableData = res.data.data
        this.total = res.data.total
      })
    },
    // 显示网络医院
    initSelectCategoryss1() {
      const params = {
        type: 1
      }
      statisticalquery(params).then(res => {
        this.over1 = res.data.over
        this.totals1 = res.data.total
      })
    },
    // 显示筛查门诊
    initSelectCategoryss2() {
      const params = {
        type: 2
      }
      statisticalquery(params).then(res => {
        this.over2 = res.data.over
        this.totals2 = res.data.total
      })
    },

    // 显示绿色通道
    initSelectCategoryss3() {
      const params = {
        type: 3
      }
      statisticalquery(params).then(res => {
        this.over3 = res.data.over
        this.totals3 = res.data.total
      })
    },

    getRowKey(row) {
      const a = sessionStorage.setItem('follow_status', 'true')
      const b = sessionStorage.setItem('cancel_status', 'false')
      const c = sessionStorage.setItem('complete_status', 'false')
      sessionStorage.setItem('state', '1')
      // sessionStorage.setItem("add_button_status", "false");
      // console.log(a, 'a')
      // console.log(b, 'b')
      // console.log(c, 'c')
      // console.log(row.patId, '哈哈哈1111')
      this.$router.push({
        path: 'follow-up-details',
        query: {
          patId: row.patId,
          /*  planPatId: row.planPatId, */
          memPatTypeCodes: row.patTypeCode,
          planId: row.planId,
          activeName: 'first',
          follow_status: sessionStorage.getItem('follow_status'),
          cancel_status: sessionStorage.getItem('cancel_status'),
          complete_status: sessionStorage.getItem('complete_status')
        }
      })
    },
    removethebaseline(row) {
      sessionStorage.setItem('follow_status', 'false')
      sessionStorage.setItem('cancel_status', 'true')
      sessionStorage.setItem('complete_status', 'true')
      sessionStorage.setItem('state', '2')
      sessionStorage.setItem('add_button_status', 'true')

      this.$router.push({
        path: 'follow-up-details',
        query: {
          patId: row.patId,
          /*  planPatId: row.planPatId, */
          memPatTypeCodes: row.patTypeCode,
          planId: row.planId,
          activeName: 'first'

        }
      })
    },
    // 点击立即随访
    click_on_immediate_follow_up() {
      this.$router.push({
        path: 'follow-up-new'
      })
    },

    // Key取值通用方法
    keyAction(item) {
      return item.code
    },
    // Value取值通用方法
    valueAction(item) {
      return item.name
    },
    /**
     * Array转Map
     * arrayObj 数组对象
     * keyAction key取值方法
     * valueAction value取值方法
     */
    arrayToMap(arrayObj, keyAction, valueAction) {
      // console.log(arrayObj)
      const res = new Map()
      // arrayObj=res.4
      const length = arrayObj.length
      for (let i = 0; i < length; i++) {
        // console.log('------' + arrayObj[i] + '------')
        res.set(keyAction(arrayObj[i]), valueAction(arrayObj[i]))
      }
      return res
    },
    arrayGetValue(arrayObj, code) {
      for (const obj in arrayObj) {
        // console.log('arrayGetValue--------', code, obj)
        if (code === obj.code) {
          return obj.name
        }
      }
      return ''
    },

    // routerBack(fid, greenType) {
    //   if (!greenType) {
    //     this.$message({
    //       message: "患者类型错误",
    //       type: "warning"
    //     });
    //     return false;
    //   } else {
    //     this.$emit("homePageToFather", { fid, greenType }); // 提醒父组件切换页面,达成返回效果
    //   }
    //   this.$emit('homePageToFather', data.dispatchId, data.patientId)
    // //   console.log(this.$router)
    //   this.$router.back()
    //   this.$router.go(-1) // 后退
    //   debugger
    //   this.$router.push('/green-channel/medicalRecords')
    //   接受子组件传来的dispatchId,patientId
    // //   console.log('传来的数据', dispatchId, patientId)
    // },
    // go() {},
    // resetForm(formName) {
    //   this.$refs[formName].resetFields();
    // },
    handleClick(tab, event) {
      this.followupState = this.followupStateList[tab.name]
      // console.log(this.followupState, '哈哈哈哈')
      this.initSelectCategoryss()
      // // console.log(tab.name, event);
    },
    // queryFollowupNum() {
    //   queryFollowupNum().then(data => {
    //     for (const key in data.data) {
    //       this.wlyy_jrsf = data.data[key];
    //       this.wlyy_jrysf = data.data[key];
    //       this.scmz_jrsf = data.data[key];
    //       this.scmz_jrysf = data.data[key];
    //       this.sh_jrsf = data.data[key];
    //       this.sh_jrysf = data.data[key];
    //       this.totals = 1;
    //     }
    //   });
    // },
    // 取消随访状态
    theechos(planPatId, planPatFollowStatusCode) {
      if (planPatFollowStatusCode != 3) {
        const params = { planPatId: planPatId }
        cancelthefollowup(params).then(data => {
          this.$message({
            message: '取消成功',
            type: 'success'
          })
          this.initSelectCategoryss()
        })
      } else {
        this.$message({
          message: '不可再取消',
          type: 'warning'
        })
      }
    },
    queryList() {
      // const params = {
      //   followupState: this.followupState,
      //   userId: this.$store.getters.userId,
      //   page: this.queryData.page,
      //   limit: this.queryData.limit,
      //   pid: this.queryData.pid,
      //   patientName: this.queryData.patientName,
      //   timeRange: this.queryData.timeRange
      //     ? this.queryData.timeRange[0] + " - " + this.queryData.timeRange[1]
      //     : "",
      //   coming_way_code: this.queryData.coming_way_code,
      //   dispatch_unit_code: this.queryData.dispatch_unit_code,
      //   is_thrombolysis: this.queryData.is_thrombolysis,
      //   throm_treatment_place: this.queryData.throm_treatment_place,
      //   outcome_code: this.queryData.outcome_code,
      //   cp_diagnosis_code: this.queryData.cp_diagnosis_code,
      //   outpatient_id: this.queryData.outpatient_id
      // };
    },

    // getTemplate() {
    //   let params = {
    //     length: this.pageSize,
    //     start: this.calStar(this.pageNum),
    //     planPatTimeEnd: this.value1[0], //任务开始
    //     planPatTimeStart: this.value1[1], //任务完成结束
    //     patName: this.formInline.patName, //姓名
    //     patSexName: this.formInline.patSexName, //性别
    //    // chronicDiseaseGrade: this.chronicDiseaseGrade, //等级
    //     patTypeCode: this.formInline.patTypeCode,
    //     chronicDiseaseGrade: this.formInline.chronicDiseaseGrade,
    //     patSexName: this.formInline.patSexName,
    //     ageRangeEnd: this.formInline.ageRangeEnd,
    //     ageRangeStart: this.formInline.ageRangeStart,
    //     userId: this.formInline.userId,
    //     // patId: this.repForms.patId,
    //     planId: this.formInline.planId,
    //     planPatFollowStatusCode: this.followupState
    //   };
    //   thebatchexport(params).then(res => {
    // //     console.log(res);
    // //     console.log("进入导入");
    //     //读取文件流为Blob
    //     const blob = res;
    //     //文件名
    //     let fileName = "随访记录导出.xlsx";
    //     // 创建新的URL并指向File对象或者Blob对象的地址
    //     const blobURL = window.URL.createObjectURL(blob);
    //     // 创建a标签，用于跳转至下载链接
    //     const tempLink = document.createElement("a");
    //     // tempLink.style.display = 'none'
    //     tempLink.href = blobURL;
    //     tempLink.setAttribute("download", decodeURI(fileName));
    //     // 兼容：某些浏览器不支持HTML5的download属性
    //     if (typeof tempLink.download === "undefined") {
    //       tempLink.setAttribute("target", "_blank");
    //     }
    //     // 挂载a标签
    //     document.body.appendChild(tempLink);
    //     tempLink.click();
    //     document.body.removeChild(tempLink);
    //     // 释放blob URL地址
    //     window.URL.revokeObjectURL(blobURL);
    //   });
    // },
    changeSize(size) {
      this.pageSize = size
      this.pageNum = 1
      this.initSelectCategoryss()
    },
    changePage(page) {
      this.pageNum = page
      this.initSelectCategoryss()
    },
    // 性别下拉选
    getDeptData() {
      const params = {
        rangeCode: 'sex'
      }
      domaininterface(params).then(res => {
        this.options = res.data
        this.comCodeList.set(
          'sex',
          this.arrayToMap(this.options, this.keyAction, this.valueAction)
        )
      })
    },
    // 患者类型
    getDeptData12(callback) {
      const params = {
        rangeCode: 'pat_type'
      }
      domaininterface(params).then(res => {
        this.options12 = res.data
        this.comCodeList.set(
          'pat_type',
          this.arrayToMap(this.options12, this.keyAction, this.valueAction)
        )
        // console.log('getDeptData12')
        // 执行16
        callback(this.getDeptData17)
      })
    },

    // 慢病等级
    getDeptData13() {
      const params = {
        rangeCode: 'chronic_disease_grade'
      }
      domaininterface(params).then(res => {
        this.options13 = res.data
        this.comCodeList.set(
          'chronic_disease_grade',
          this.arrayToMap(this.options13, this.keyAction, this.valueAction)
        )
      })
    },
    // 医生下拉选
    getDeptData4() {
      thedoctor().then(res => {
        this.options4 = res.data
        // this.comCodeList.set(
        //   "thedoctor",
        //   this.arrayToMap(this.options4, this.keyAction, this.valueAction)
        // );
      })
    },
    // 随访计划
    getDeptData15(callback) {
      followupplan().then(res => {
        this.options15 = res.data
        // this.comCodeList.set(
        //   "followupplan",
        //   this.arrayToMap(this.options15, this.keyAction, this.valueAction)
        // );
      })
    },
    // 随访方式
    getDeptData16(callback) {
      const params = {
        rangeCode: 'follow_way'
      }
      domaininterface(params).then(res => {
        // console.log(this.options12)
        this.comCodeList.set(
          'follow_way',
          this.arrayToMap(res.data, this.keyAction, this.valueAction)
        )
        // console.log('getDeptData16')
        // 17
        callback(this.getDeptData18)
      })
    },
    // 随访状态
    getDeptData17(callback) {
      const params = {
        rangeCode: 'follow_status'
      }
      domaininterface(params).then(res => {
        this.comCodeList.set(
          'follow_status',
          this.arrayToMap(res.data, this.keyAction, this.valueAction)
        )
        // console.log('getDeptData17')
        // 18
        callback(this.getDeptData19)
      })
    },

    // 计划周期
    getDeptData18(callback) {
      const params = {
        rangeCode: 'plan_cycle'
      }
      domaininterface(params).then(res => {
        this.comCodeList.set(
          'plan_cycle',
          this.arrayToMap(res.data, this.keyAction, this.valueAction)
        )
        // console.log('getDeptData18')
        // 19
        callback(this.initSelectCategoryss)
      })
    },
    // 随访次数
    getDeptData19(callback) {
      const params = {
        rangeCode: 'plan_frequency'
      }
      domaininterface(params).then(res => {
        this.comCodeList.set(
          'plan_frequency',
          this.arrayToMap(res.data, this.keyAction, this.valueAction)
        )
        // console.log('getDeptData19')
        // 初始化数据
        callback()
      })
    },
    // 查询
    queryinformation() {
      this.initSelectCategoryss()
    },
    // 重置
    reset() {
      this.formInline.patName = ''
      this.formInline.planId = ''
      this.formInline.chronicDiseaseGrade = ''
      this.value1 = ['', '']
      this.formInline.patTypeCode = ''
      this.formInline.patSexName = ''
      this.formInline.userId = ''
      this.formInline.ageRangeEnd = ''
      this.formInline.ageRangeStart = ''
    },
    // Key取值通用方法
    keyAction(item) {
      return item.code
    },
    // Value取值通用方法
    valueAction(item) {
      return item.name
    },
    /**
     * Array转Map
     * arrayObj 数组对象
     * keyAction key取值方法
     * valueAction value取值方法
     */
    arrayToMap(arrayObj, keyAction, valueAction) {
      const res = new Map()
      // arrayObj=res.4
      const length = arrayObj.length
      for (let i = 0; i < length; i++) {
        // console.log('------' + arrayObj[i] + '------')
        res.set(keyAction(arrayObj[i]), valueAction(arrayObj[i]))
      }
      return res
    },
    arrayGetValue(arrayObj, code) {
      for (const obj in arrayObj) {
        // console.log('arrayGetValue--------', code, obj)
        if (code === obj.code) {
          return obj.name
        }
      }
      return ''
    }
  }
}
</script>

<style lang="scss" scoped>
.icon {
  font-size: 24px;
}
.font13 {
  font-size: 13px;
}
#topInfo {
  width: 100%;
  padding: 15px 20px;
  border-bottom: 10px #eee solid;
}
#btmForm {
  padding: 20px 20px 0;
}
.fontWhite {
  color: #fff;
}
.title_gailan_middle {
  width: 32.2%;
  height: 120px;
  margin-right: 10px;
  border: 1px solid #dddddd;
  border-radius: 3px;
  display: inline-block;
  position: relative;
}
.title_gailan_top {
  margin-top: 18px;
  margin-left: 20px;
  margin-bottom: 10px;
  font-size: 16px;
}
.title_gailan_radio {
  width: 46%;
  height: 70px;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  display: inline-block;
  line-height: 75px;
  position: absolute;
  bottom: 0;
  font-size: 12px;
}
.jrsf {
  /* file:///D:/svnTest/code/trunk/yzy_web_vue/src/images/follow_images/sfjl2.png */
  background: url("~@/images/follow_images/sfjl1.png") no-repeat;
  filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale')";
  -moz-background-size: 100% 100%;
  background-size: 100% 100%;
  /* background-size: cover; */
  /* margin: 0 3%; */
  left: 3%;
}
.jrysf {
  /* float: right; */
  /* margin-right: 20px; */
  background: url("~@/images/follow_images/sfjl2.png") no-repeat;
  filter: "progid:DXImageTransform.Microsoft.AlphaIma geLoader(sizingMethod='scale')";
  -moz-background-size: 100% 100%;
  background-size: 100% 100%;
  right: 3%;
}
.title_gailan_left_middle {
  /* float: left; */
  /* position: relative; */
  /* left: 15px; */
  margin-left: 5%;
  font-size: 15px;
  line-height: 70px;
  margin-left: 5%;
}
.title_gailan_right_middle {
  position: absolute;
  right: 0px;
  font-weight: 300;
  font-size: 20px;
}
.title_gailan_line {
  font-size: 18px;
  position: absolute;
  left: 60%;
  top: -2px;
}
</style>
